package com.telit.dispose.service.dispose.impl;

import com.telit.dispose.service.dispose.DataSelectPageService;
import com.telit.dispose.service.dispose.PlatMetaTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * Create by Chencf 2022/08/05
 */

@Service
public class DataSelectPageServiceImpl implements DataSelectPageService {

    @Autowired
    private PlatMetaTableService platMetaTableService;

    @Override
    public Object dateSelectByService(String tableId, String service,
                                      Integer current, Integer size,
                                      String name, String data,
                                      String detailId, String xzqhcode) {
        Object result = null;
        switch (service) {
            //查询使用的配置信息  也就是表的信息
            case "/type/listConfigure":
                result = platMetaTableService.findTypeList();
                break;
            //在点击对应的菜单名称请求接口    表id在上面一个接口里面会以tableid给到前端
            case "/type/info":
                result = platMetaTableService.findInfo(tableId);
                break;
            //查询对应的表的分页信
            case "/type/pageList":
                result = platMetaTableService.pageList(tableId, current, size, name, xzqhcode);
                break;
            //添加对应表数据  需要传对应表id和data数据  data   json类型的即可
            case "/type/save":
                result = platMetaTableService.save(tableId, data);
                break;
            //查看详情
            case "/type/detail":
                result = platMetaTableService.detail(tableId, detailId);
                break;
            //修改数据  data为修改数据的json
            case "/type/edit":
                result = platMetaTableService.edit(tableId, detailId, data);
                break;
            //删除数据    后端直接将对应数据下线即可  均为软删除
            case "/type/delete":
                result = platMetaTableService.delete(tableId, detailId);
                break;
            default:
                break;

        }
        return result;
    }

}
